﻿<!--#include file="h.asp"--><%
'
'	七色虎建站系统
'	用户收藏页面
'	2012.9.12

'TODO 暂时不开放列表和论坛

Sub main
	checkLogin()'验证登录
	Dim a,userid,rs,body_,rss,sort,sqlEx
	Dim name,nameLen,classId,subId,ok,id
	Dim sql,pageSize,count,page,i,pagecount
	hu.title = "我的收藏夹"
	body_ = "[div=nav]-"&hu.url("?aid=index","首页")&"-"&hu.url("bbs_user.asp","会员中心")&"-收藏夹[/div]"
	a=getN("a", 0)
	userid=user_array(0)
	If a=0 Then'收藏列表
		sort=getData("sort")
		page=getN("page",1)
		Select Case sort
		Case "art"'只显示文章
			sqlEx = "and type=2"
			body_ = body_ & "显示"&hu.url("bbs_keep.asp","全部")&".文章."&hu.url("bbs_keep.asp?sort=post","帖子")
		Case "post"'只显示帖子
			sqlEx = "and type=3"
			body_ = body_ & "显示"&hu.url("bbs_keep.asp","全部")&"."&hu.url("bbs_keep.asp?sort=art","文章")&".帖子"
		' Case "bbs"'只显示论坛
			' sqlEx = "and type=1"
			' body_ = body_ & "显示"&hu.url("bbs_keep.asp","全部")&"."&hu.url("bbs_keep.asp?sort=art","文章")&"."&_
				' hu.url("bbs_keep.asp?sort=post","帖子")
		Case Else'显示全部
			body_ = body_ & "显示全部."&hu.url("bbs_keep.asp?sort=art","文章")&"."&hu.url("bbs_keep.asp?sort=post","帖子")
		End Select
		sql="select id,type,subtype from 74hu_bookmark where userid="&userid&" "&sqlEx&" order by id desc"
		Set rs = Server.CreateObject("ADODB.Recordset")
		rs.open sql, hu.db, 1, 1
		body_ = body_ & "<br/>"
		If Not rs.eof then
			count = rs.recordcount
			PageSize=numList
			if page<=0 or page="" then page=1
			pagecount=(count+pagesize-1)\pagesize
			if page>pagecount then page=pagecount
			rs.move(pagesize*(page-1))
			body_ = body_ & "有"&count&"条收藏<br/>"
			For i=1 To PageSize
				If rs.eof Then Exit For
				If (i mod 2)=0 Then
					class_="even"
				Else
					class_="odd"
				End If
				classId = rs("type")
				subId = rs("subtype")
				body_=body_&"[div="&class_&"]"&i+(page-1)*PageSize&"."
				Select Case classId
				' Case 1'论坛
					' Set rss=hu.conn("select top 1 name from 74hu_bbs where classid="&subId)
					' If Not rss.eof Then
						' body_=body_& "" &hu.url("bbs_topic.asp?id="&subId, nowml(getLeft(rss("name"),10)))
					' Else
						' body_=body_& "内容已删除"
					' End If
				Case 2'文章
					Set rss=hu.conn("select top 1 title from 74hu_article where id="&subId)
					If Not rss.eof Then
						body_=body_& "" &hu.url("article.asp?id="&subId, nowml(getLeft(rss("title"),10)))
					Else
						body_=body_& "内容已删除"
					End If
				Case 3'帖子
					Set rss=hu.conn("select top 1 title from 74hu_topic where id="&subId)
					If Not rss.eof Then
						body_=body_& "" &hu.url("bbs_posts.asp?id="&subId, nowml(getLeft(rss("title"),10)))
					Else
						body_=body_& "内容已删除"
					End If
				Case Else
				End Select
				body_=body_& "["&hu.url("bbs_keep.asp?a=2&amp;id="&rs("id")&"&amp;sort="&sort&"&amp;page="&page,"删")&"][/div]"
				rs.moveNext
			Next
			Set rss=Nothing
			body_= body_ & showPage("bbs_keep.asp", "sort:"&sort, page, pagecount)
		Else
			body_= body_ & "暂时没有收藏<br/>"
		End If
		Set rs=Nothing
	ElseIf a=1 Then'保存收藏
		classId=getN("classid", 0)
		subId=getN("id", 0)
		If classId=0 Or subId=0 Then rupt "错误", "参数Id错误"
		If classId<>1 And classId<>2 And classId<>3 Then rupt "错误", "参数Id错误"
		Set rs=hu.conn("select top 1 id from 74hu_bookmark where userid="&userid&" and type="&classId&" and subtype="&subId)
		If Not rs.eof Then
			body_ = body_ & "已收藏过，请不要重复收藏！"
		Else
			hu.conn("insert into 74hu_bookmark (userid,type,subtype)values("&userid&","&classId&","&subId&")")
			body_ = body_ & "收藏保存成功！"
		End If
		Set rs=Nothing
		body_ = body_ & hu.url("bbs_keep.asp","返回收藏夹")
	ElseIf a=2 Then'删除收藏
		sort=getData("sort")
		id=getN("id", 0)
		page=getN("page",1)
		If getData("ok")="" Then
			body_ = body_ & "确定要删除这条收藏吗？<br/>"& hu.url("bbs_keep.asp?a=2&amp;ok=true&amp;id="&id&"&amp;sort="&sort&"&amp;page="&page,"是，删除该收藏")&_
				"<br/>"&hu.url("bbs_keep.asp?sort="&sort&"&amp;page="&page,"否，返回收藏夹")
		Else
			hu.conn("delete from 74hu_bookmark where userid="&userid&" and id="&id)
			body_ = body_ &"删除成功！"&hu.url("bbs_keep.asp?sort="&sort&"&amp;page="&page,"返回收藏夹")
		End If
	Else
		body_ = body_ & hu.url("bbs_keep.asp","返回收藏夹")
	End If
	hu.body = comUbb(body_)
End Sub

%>